using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.iMass;

public class FormAddUser : Form
{
	private IContainer components = null;

	private Label lblUser;

	private Label lblPsw;

	private Label lblAuthor;

	private TextBox txtUser;

	private TextBox txtPsw;

	private ComboBox cbAuthor;

	private Button btnAdd;

	private Button btnClose;

	private Label lblTip;

	private Label lblTipCont;

	public FormAddUser()
	{
		InitializeComponent();
	}

	private void FormAddUser_Load(object sender, EventArgs e)
	{
		cbAuthor.Items.Add(Lang.Txt("AddiMass.Text1"));
		cbAuthor.Items.Add(Lang.Txt("AddiMass.Text2"));
		cbAuthor.SelectedIndex = 0;
	}

	private void btnAdd_Click(object sender, EventArgs e)
	{
		string name = txtUser.Text;
		string psw = txtPsw.Text;
		UserManager.Authority author = (UserManager.Authority)cbAuthor.SelectedIndex;
		name.Trim();
		psw.Trim();
		if (!UserManager.Instance.AddUser(name, psw, author))
		{
			lblTip.Visible = true;
			lblTipCont.Visible = true;
			lblTipCont.Text = Lang.Txt("AddiMass.Text3");
		}
		else
		{
			base.DialogResult = DialogResult.OK;
		}
	}

	private void button2_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.lblUser = new System.Windows.Forms.Label();
		this.lblPsw = new System.Windows.Forms.Label();
		this.lblAuthor = new System.Windows.Forms.Label();
		this.txtUser = new System.Windows.Forms.TextBox();
		this.txtPsw = new System.Windows.Forms.TextBox();
		this.cbAuthor = new System.Windows.Forms.ComboBox();
		this.btnAdd = new System.Windows.Forms.Button();
		this.btnClose = new System.Windows.Forms.Button();
		this.lblTip = new System.Windows.Forms.Label();
		this.lblTipCont = new System.Windows.Forms.Label();
		base.SuspendLayout();
		this.lblUser.Location = new System.Drawing.Point(12, 31);
		this.lblUser.Name = "lblUser";
		this.lblUser.Size = new System.Drawing.Size(84, 23);
		this.lblUser.TabIndex = 0;
		this.lblUser.Text = "用户名:";
		this.lblUser.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
		this.lblPsw.Location = new System.Drawing.Point(12, 63);
		this.lblPsw.Name = "lblPsw";
		this.lblPsw.Size = new System.Drawing.Size(84, 23);
		this.lblPsw.TabIndex = 1;
		this.lblPsw.Text = "密码:";
		this.lblPsw.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
		this.lblAuthor.Location = new System.Drawing.Point(12, 94);
		this.lblAuthor.Name = "lblAuthor";
		this.lblAuthor.Size = new System.Drawing.Size(84, 23);
		this.lblAuthor.TabIndex = 2;
		this.lblAuthor.Text = "权限:";
		this.lblAuthor.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
		this.txtUser.Location = new System.Drawing.Point(102, 32);
		this.txtUser.Name = "txtUser";
		this.txtUser.Size = new System.Drawing.Size(129, 21);
		this.txtUser.TabIndex = 3;
		this.txtUser.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
		this.txtPsw.Location = new System.Drawing.Point(102, 65);
		this.txtPsw.Name = "txtPsw";
		this.txtPsw.Size = new System.Drawing.Size(129, 21);
		this.txtPsw.TabIndex = 4;
		this.txtPsw.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
		this.cbAuthor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbAuthor.FormattingEnabled = true;
		this.cbAuthor.Location = new System.Drawing.Point(102, 96);
		this.cbAuthor.Name = "cbAuthor";
		this.cbAuthor.Size = new System.Drawing.Size(129, 20);
		this.cbAuthor.TabIndex = 5;
		this.btnAdd.Location = new System.Drawing.Point(45, 135);
		this.btnAdd.Name = "btnAdd";
		this.btnAdd.Size = new System.Drawing.Size(75, 23);
		this.btnAdd.TabIndex = 6;
		this.btnAdd.Text = "添加";
		this.btnAdd.UseVisualStyleBackColor = true;
		this.btnAdd.Click += new System.EventHandler(btnAdd_Click);
		this.btnClose.Location = new System.Drawing.Point(145, 135);
		this.btnClose.Name = "btnClose";
		this.btnClose.Size = new System.Drawing.Size(75, 23);
		this.btnClose.TabIndex = 7;
		this.btnClose.Text = "关闭";
		this.btnClose.UseVisualStyleBackColor = true;
		this.btnClose.Click += new System.EventHandler(button2_Click);
		this.lblTip.ForeColor = System.Drawing.Color.Red;
		this.lblTip.Location = new System.Drawing.Point(-1, 0);
		this.lblTip.Name = "lblTip";
		this.lblTip.Size = new System.Drawing.Size(82, 23);
		this.lblTip.TabIndex = 8;
		this.lblTip.Text = "提示:";
		this.lblTip.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
		this.lblTip.Visible = false;
		this.lblTipCont.ForeColor = System.Drawing.Color.Red;
		this.lblTipCont.Location = new System.Drawing.Point(87, 0);
		this.lblTipCont.Name = "lblTipCont";
		this.lblTipCont.Size = new System.Drawing.Size(173, 23);
		this.lblTipCont.TabIndex = 9;
		this.lblTipCont.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.lblTipCont.Visible = false;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(266, 170);
		base.Controls.Add(this.lblTipCont);
		base.Controls.Add(this.lblTip);
		base.Controls.Add(this.btnClose);
		base.Controls.Add(this.btnAdd);
		base.Controls.Add(this.cbAuthor);
		base.Controls.Add(this.txtPsw);
		base.Controls.Add(this.txtUser);
		base.Controls.Add(this.lblAuthor);
		base.Controls.Add(this.lblPsw);
		base.Controls.Add(this.lblUser);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "FormAddUser";
		base.ShowIcon = false;
		this.Text = "添加用户";
		base.Load += new System.EventHandler(FormAddUser_Load);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
